const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('category', {
    category_id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    category_name: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: "",
      comment: "分类名称"
    },
    sort: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "排序顺序"
    },
    is_show: {
      type: DataTypes.TINYINT,
      allowNull: true,
      defaultValue: 0,
      comment: "是否展示： 0-不展示 ，1-展示"
    },
    add_date: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0
    },
    intro: {
      type: DataTypes.STRING(200),
      allowNull: true,
      defaultValue: "",
      comment: "分类简介"
    },
    admin_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "关联管理员id"
    }
  }, {
    sequelize,
    tableName: 'category',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "category_id" },
        ]
      },
    ]
  });
};
